package com.sniper.mybatis.service.impl;

import com.sniper.model.LineShop;
import com.sniper.mybatis.dao.BaseDao;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


/**
 * @author suzhen
 */
@Service("lineShopService")
public class LineShopServiceImpl extends BaseServiceImpl<LineShop> implements LineShopService {

    @Resource
    @Override
    public void setDao(BaseDao<LineShop> dao) {
        super.setDao(dao);
    }


    @Override
    public LineShop getTitle(String title) {
        Map<String, Object> params = new HashMap<>(1);
        params.put("title", title);
        List<LineShop> lineShops = this.query("select", params);
        if (lineShops.size() > 0) {
            return lineShops.get(0);
        }
        return null;
    }

    @Override
    public LineShop getShopCode(String shopCode) {
        if (StringUtils.isNotBlank(shopCode)) {
            Map<String, Object> params = new HashMap<>(1);
            params.put("unShopCode", shopCode);
            return (LineShop) this.find(params);
        }
        return null;
    }

    @Override
    public LineShop getUnCode(String unCode) {
        if (StringUtils.isNotBlank(unCode)) {
            Map<String, Object> params = new HashMap<>(1);
            params.put("unCode", unCode);
            return (LineShop) this.find(params);
        }
        return null;
    }
}